package com.chat.api.web.dao;


import com.chat.api.common.BaseRepo;
import com.chat.api.web.po.UserBean;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserRepo extends BaseRepo<UserBean,Long> {

    @Query(value = "select * from user where username = ?1", nativeQuery = true)
    UserBean queryByUsername(String username);

    @Query(value = "select username,praise,image,head from user" ,nativeQuery = true)
    List<UserBean> findAllMain();

    @Query(value = "select * from user where id = ?1", nativeQuery = true)
    UserBean findByUserId(Long userId);

    @Query(value = "select * from user where name = ?1", nativeQuery = true)
    UserBean queryByName(String name);

    @Query(value = "select * from user where id <> ?1 order by id", nativeQuery = true)
    List<UserBean> findAllNotSelf(Long userId);

    @Query(value = "select * from user where name = ?1", nativeQuery = true)
    UserBean findByName(String name);
}
